package com.dailyblue.java;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;

import java.io.*;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Student implements Serializable {

    private static final long serialVersionUID = 1234;

    private Integer id;
    private String name;

    @SneakyThrows
    public void writeObject(OutputStream out) {
        ObjectOutputStream ooos = new ObjectOutputStream(out);
        ooos.writeObject(this);
    }

    @SneakyThrows
    public Object readObject(InputStream in) {
        ObjectInputStream ois = new ObjectInputStream(in);
        return ois.readObject();

    }
}
